package com.shiliao.app.dialog;

import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.shiliao.app.R;
import com.yimei.framework.ui.dilaog.AnimationType;
import com.yimei.framework.ui.dilaog.YimeiBaseDialog;

/**
 * Created by yinzhiqiang on 2017/10/28.
 */

public class OpenLocationDialog extends YimeiBaseDialog {
    private TextView mComfrin;
    private TextView mCancle;
    private TextView mDialogTitle;
    private TextView mDialogMessage;

    /**
     * 构造函数.
     *
     * @param activity context
     */
    public OpenLocationDialog(Activity activity) {
        super(activity);
        if (activity != null && mDialog != null) {
            mActivity = activity;
            if (null == getLayoutInflater()) {
                return;
            }
            mContainerView = getLayoutInflater().inflate(R.layout.dialog_open_location, null);
            mDialog.setCanceledOnTouchOutside(false);
            mComfrin = (TextView) mContainerView.findViewById(R.id.tv_confirm);
            mCancle = (TextView) mContainerView.findViewById(R.id.tv_cancle);
            mDialogTitle = (TextView) mContainerView.findViewById(R.id.dialog_title);
            mDialogMessage = (TextView) mContainerView.findViewById(R.id.dialog_message);
            mWindow.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER);
            mWindow.setWindowAnimations(mAnimations[AnimationType.TOAST_FADE
                    .getValue()]);
        }
    }

    @Override
    public void show(boolean isAutoDismiss) {
        super.show(isAutoDismiss);
        WindowManager.LayoutParams layoutParams = mDialog.getWindow().getAttributes();
        layoutParams.gravity = Gravity.CENTER;
//        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
//        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        mDialog.getWindow().setAttributes(layoutParams);
    }

    public void setComfirn(View.OnClickListener listener) {
        if (mActivity != null && mComfrin != null) {
            mComfrin.setOnClickListener(listener);
        }

    }

    public void setComfrinBtn(String mess) {
        if (mActivity != null && mComfrin != null) {
            mComfrin.setText(mess);
        }
    }

    public void setCancle(View.OnClickListener listener) {
        if (mActivity != null && mCancle != null) {
            mCancle.setOnClickListener(listener);
        }

    }

    public void setCancelText(String text) {
        if (mActivity != null && mComfrin != null) {
            mCancle.setText(text);
        }
    }

    public void setmComfrinText(String text) {
        if (mActivity != null && mComfrin != null) {
            mComfrin.setText(text);
        }
    }

    public void setTitle(String title) {
        if (mActivity != null && mDialogTitle != null) {
            mDialogTitle.setText(title);
        }
    }

    public void setContentMessage(String message) {
        if (mActivity != null && mDialogMessage != null) {
            mDialogMessage.setText(message);
        }
    }
}
